//
//  BaseViewController.m
//  Payment
//
//  Created by  ztryxh on 2018/2/27.
//  Copyright © 2018年 ebo. All rights reserved.
//

#import "BaseViewController.h"
#import "CheckViewController.h"
#import "HomeViewController.h"
#import "WalletDetailsController.h"
@interface BaseViewController ()
{
    
    
}
@end

@implementation BaseViewController
#pragma mark - life Cycle
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    if ([self isKindOfClass:[CheckViewController class]]||[self isKindOfClass:[HomeViewController class]]||[self isKindOfClass:[WalletDetailsController class]]) {
        [self.navigationController setNavigationBarHidden:YES animated:YES];
        if ([self isKindOfClass:[CheckViewController class]]) {
            [UIApplication sharedApplication].statusBarStyle=UIStatusBarStyleDefault;

        }else
        {
            [UIApplication sharedApplication].statusBarStyle=UIStatusBarStyleLightContent;

        }
        

    }else
    {
        [self.navigationController setNavigationBarHidden:NO animated:YES];
        [UIApplication sharedApplication].statusBarStyle=UIStatusBarStyleLightContent;

    }
}
- (void)viewDidLoad {
    
    [super viewDidLoad];
    [[self.navigationController.navigationBar subviews] objectAtIndex:0].alpha = 1;
    
    UIImage *bgImage = kImageName(@"icon_nav_bg");
    bgImage = [bgImage resizableImageWithCapInsets:UIEdgeInsetsZero resizingMode:UIImageResizingModeStretch];
    [self.navigationController.navigationBar setBackgroundImage:bgImage forBarMetrics:UIBarMetricsDefault];
    
    self.view.backgroundColor = kGlobalBackCorlor;
    self.navigationController.navigationBar.barTintColor = kNavTitleColor;
    [self.navigationController.navigationBar setTitleTextAttributes:
     @{NSFontAttributeName:[UIFont systemFontOfSize:17],
       NSForegroundColorAttributeName:kNavTitleColor}];

    [self leftItemBack];//替换返回按钮

}


-(void)leftItemBack{
    UIButton *leftBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    [leftBtn setFrame:CGRectMake(0, 0, 40, 40)];
    [leftBtn setImage:[UIImage imageNamed:@"icon_left_arrow"] forState:UIControlStateNormal];
    [leftBtn setImageEdgeInsets:UIEdgeInsetsMake(0, -8, 0, 8)];
    [leftBtn addTarget:self action:@selector(returnbtn) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *leftBarButtomItem = [[UIBarButtonItem alloc]initWithCustomView:leftBtn];
    self.navigationItem.leftBarButtonItem = leftBarButtomItem;
}
-(void)returnbtn{

    [self.navigationController popViewControllerAnimated:YES];
}

@end
